What is @aws-crypto/raw-keyring?
@aws-crypto/raw-keyring is a package provided by AWS that allows developers to use raw keyrings for cryptographic operations. This package is part of the AWS Encryption SDK and is used to encrypt and decrypt data using raw cryptographic keys.
What are @aws-crypto/raw-keyring's main functionalities?
Encrypting Data
This feature allows you to encrypt data using a raw AES keyring. The code sample demonstrates how to create a RawAesKeyringNode and use it to encrypt a plaintext string.
const { RawAesKeyringNode } = require('@aws-crypto/raw-keyring');
const { encrypt } = require('@aws-crypto/client-node');
const keyName = 'example-key-name';
const keyNamespace = 'example-key-namespace';
const unencryptedMasterKey = Buffer.from('00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff', 'hex');
const keyring = new RawAesKeyringNode({
keyName,
keyNamespace,
unencryptedMasterKey
});
const plaintext = 'Hello, World!';
(async () => {
const { result } = await encrypt(keyring, plaintext);
console.log(result);
})();
Decrypting Data
This feature allows you to decrypt data that was encrypted using a raw AES keyring. The code sample demonstrates how to create a RawAesKeyringNode and use it to decrypt an encrypted data buffer.
const { RawAesKeyringNode } = require('@aws-crypto/raw-keyring');
const { decrypt } = require('@aws-crypto/client-node');
const keyName = 'example-key-name';
const keyNamespace = 'example-key-namespace';
const unencryptedMasterKey = Buffer.from('00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff', 'hex');
const keyring = new RawAesKeyringNode({
keyName,
keyNamespace,
unencryptedMasterKey
});
const encryptedData = /* previously encrypted data */;
(async () => {
const { plaintext } = await decrypt(keyring, encryptedData);
console.log(plaintext.toString());
})();
Other packages similar to @aws-crypto/raw-keyring
crypto
The 'crypto' module in Node.js provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions. Unlike @aws-crypto/raw-keyring, it does not provide a high-level abstraction for key management and encryption/decryption operations.
node-forge
Node-forge is a JavaScript library that provides a native implementation of TLS (and various other cryptographic tools) in JavaScript. It offers more granular control over cryptographic operations compared to @aws-crypto/raw-keyring, but does not integrate directly with AWS services.
sjcl
Stanford Javascript Crypto Library (SJCL) is a library for cryptography in JavaScript. It is designed to be secure, fast, and easy to use. SJCL provides a variety of cryptographic primitives but does not offer the same level of integration with AWS services as @aws-crypto/raw-keyring.
aws-encryption-sdk-javascript
The AWS Encryption SDK for JavaScript is a client-side encryption library designed to make it easy for everyone to encrypt and decrypt data using industry standards and best practices. It uses a data format compatible with the AWS Encryption SDKs in other languages. For more information on the AWS Encryption SDKs in all languages, see the Developer Guide.
About @aws-crypto/raw-keyring
This package is not intended for direct use by clients. To get started with the AWS Encryption SDK for JavaScript, follow the instructions in the README.
License
This SDK is distributed under the
Apache License, Version 2.0,
see LICENSE.txt and NOTICE.txt for more information.